#pragma once

class GameObject;
#include <vector>

#include "../SGD Wrappers/SGD_Geometry.h"
class ObjectManager
{
public:

	/**********************************************************/
	// Typedefs will simplify the templates
	typedef std::vector< GameObject* >		ObjectVector;
	typedef std::vector< ObjectVector >	ObjectTable;

	ObjectManager() = default;
	~ObjectManager() = default;


	/**********************************************************/
	// Objecty Storage:
	void	AddObject(GameObject* pObject, unsigned int bucket);
	void	RemoveObject(GameObject* pObject, unsigned int bucket);
	void	RemoveObject(GameObject* pObject);
	void	RemoveAllFromBucket(unsigned int bucket);
	void	RemoveAll(void);
	bool	IsEmpty(unsigned int bucket);
	void	CleanUpAugments();
	GameObject* ReturnClosestEnemy();
	/**********************************************************/
	// Object Upkeep:
	void	UpdateAll(float elapsedTime);
	void	RenderAll(void);

	void	CheckCollisions(unsigned int bucket1, unsigned int bucket2);

	unsigned int GetBucketCount(void) const { return m_iBucketCount; }
	GameObject* ReturnObject(unsigned int bucket, unsigned int index);

	ObjectTable GetTable() { return m_tObjects; }

private:
	/**********************************************************/
	// Not a singleton, but still don't want the Trilogy-of-Evil
	ObjectManager(const ObjectManager&) = delete;
	ObjectManager& operator= (const ObjectManager&) = delete;


	/**********************************************************/
	// members:
	unsigned int	m_iBucketCount = 0;		// Bucket Count
	ObjectTable	m_tObjects;					// vector-of-vector-of-GameObjects* (2D table)
	bool		m_bIterating = false;	// read/write lock


};

